package com.lanou3g.code0418.control;

/**
 * Created by dllo on 18/4/18.
 */
public class Test02 {
    public static void main(String[] args) {
        Thread a = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println(i);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        a.start();

        try {
            //join()让当前线程(主线程)插入另一个线程对象(a)
            //当前线程等待a线程先执行完,再执行本身线程
            a.join();
            //b.join();若有b 此时保证a执行完毕再执行b
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("主线程执行完毕");
    }
}
